import 'package:flu_framework/common/base/BaseWidget.dart';
import 'package:flu_framework/common/utility/config.dart';
import 'package:flu_framework/common/widgets/dialog_utils.dart';
import 'package:flutter/material.dart';
import 'package:umeng_common_sdk/umeng_common_sdk.dart';

class UMengPage extends BaseWidget {
  const UMengPage({super.key});

  @override
  BaseWidgetState<BaseWidget> getState()  => _UMengPageState();
}

class _UMengPageState extends BaseWidgetState<UMengPage> {

  @override
  String setPageTitle() => "友盟页面";

  @override
  Widget buildContent() {
    return Center(
      child: Column(
        children: [
          ElevatedButton(
            onPressed: () async {
              bool privacy = await DialogUtils.showPrivacyDialog(context);
              if(privacy){
                print("ah  privacy");
                Config.initUM();
              }
            },
            child: Text("友盟初始化"),
          ),
          ElevatedButton(
            onPressed: (){
              Map<String,dynamic> properties = Map();
              properties["my_id"] = "123";
              properties["my_data"] = "afafaf";
              UmengCommonSdk.onEvent("myevent", properties);
              print("send event success");
            },
            child: Text("发送友盟自定义数据"),
          ),
        ],
      ),
    );
  }


}
